﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Submarines
{
    public partial class Setup : UserControl
    {
        public Setup()
        {
            InitializeComponent();
        }

        void HSubmarine(int x, int y, int size)
        {
            Button Submarine = new Button();

            Submarine = new Button();
            Submarine.Location = new Point(x + 30, y);
            Submarine.Name = "H"+size.ToString();
            Submarine.Tag = (5 - size).ToString();
            Submarine.Size = new Size(30 * size, 30);
            Submarine.MouseMove += new MouseEventHandler(Submarine_MouseMove);
            Controls.Add(Submarine);
        }

        void VSubmarine(int x, int y, int size)
        {
            Button Submarine = new Button();

            Submarine = new Button();
            Submarine.Location = new Point(x + 30, y);
            Submarine.Name = "V"+size.ToString();
            Submarine.Tag = (5 - size).ToString();
            Submarine.Size = new Size(30, 30 * size);
            Submarine.MouseMove += new MouseEventHandler(Submarine_MouseMove);
            Controls.Add(Submarine);
        }

        void Submarine_MouseMove(object sender, MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
                DoDragDrop(sender, DragDropEffects.Link);
        }

        private void Setup_Load(object sender, EventArgs e)
        {
            HSubmarine(10, 10, 4);
            HSubmarine(10, 40, 3);
            HSubmarine(10, 70, 2);
            HSubmarine(10, 100, 1);

            VSubmarine(10, 130, 4);
            VSubmarine(40, 130, 3);
            VSubmarine(70, 130, 2);
            VSubmarine(100, 130, 1);
        }
    }
}
